//******************************************************************************
//  _____                  _    _             __
// |  _  |                | |  | |           / _|
// | | | |_ __   ___ _ __ | |  | | __ _ _ __| |_ __ _ _ __ ___
// | | | | '_ \ / _ \ '_ \| |/\| |/ _` | '__|  _/ _` | '__/ _ \
// \ \_/ / |_) |  __/ | | \  /\  / (_| | |  | || (_| | | |  __/
//  \___/| .__/ \___|_| |_|\/  \/ \__,_|_|  |_| \__,_|_|  \___|
//       | |               We don't make the game you play.
//       |_|                 We make the game you play BETTER.
//
//            Website: http://openwarfaremod.com/
//******************************************************************************

#include openwarfare\_utils;

init()
{
	printDebugLine( "openwarfare\globalinit::init()" );
	
	// Initialize the arrays to hold the gametype names and stock map names
	initGametypesAndMaps();

	// Do not thread these initializations
	openwarfare\_eventmanager::eventManagerInit();

	thread openwarfare\_antibunnyhopping::init();
	thread openwarfare\_anticamping::init();
	thread openwarfare\_bodyremoval::init();
	thread openwarfare\_blackscreen::init();
	thread openwarfare\_bloodsplatters::init();
	thread openwarfare\_damageeffect::init();
	thread openwarfare\_dogtags::init();
	thread openwarfare\_extendedobituaries::init();
	thread openwarfare\_fitnesscs::init();
	thread openwarfare\_guidcs::init();
	//thread openwarfare\_healthsystem::init();
	thread openwarfare\_idlemonitor::init();
    thread openwarfare\_keybinds::init();
	thread openwarfare\_numlives::init();
	thread openwarfare\_rangefinder::init();
	thread openwarfare\_rng::init();
	thread openwarfare\_rotateifempty::init();
	thread openwarfare\_serverbanners::init();
	thread openwarfare\_servermessages::init();
	thread openwarfare\_spawnprotection::init();
	thread openwarfare\_speedcontrol::init();
	thread openwarfare\_sponsors::init();
	thread openwarfare\_timer::init();
	thread openwarfare\_teamstatus::init();
	thread openwarfare\_thirdperson::init();
	thread openwarfare\_weapondamagemodifier::init();
	thread openwarfare\_weaponlocationmodifier::init();
	thread openwarfare\_weaponrangemodifier::init();
	
	
}


initGametypesAndMaps()
{
	// ********************************************************************
	// WE DO NOT USE LOCALIZED STRINGS TO BE ABLE TO USE THEM IN MENU FILES
	// ********************************************************************

	// Load all the gametypes we currently support
	level.supportedGametypes = [];
	level.supportedGametypes["ctf"] = "Capture The Flag";
	level.supportedGametypes["dem"] = "Demolition";
	level.supportedGametypes["dom"] = "Domination";
	level.supportedGametypes["koth"] = "Headquarters";
	level.supportedGametypes["sab"] = "Sabotage";
	level.supportedGametypes["sd"] = "Search & Destroy";
	level.supportedGametypes["tdm"] = "Team Deathmatch";

	if( !isDefined( level.scr_shift_freezetag ) || !level.scr_shift_freezetag ) {
		level.supportedGametypes["dm"] = "Free For All";
		level.supportedGametypes["gun"] = "Gun Game";
		level.supportedGametypes["hlnd"] = "Sticks and Stones";
		level.supportedGametypes["oic"] = "One in the Chamber";
		level.supportedGametypes["shrp"] = "Sharp Shooter";
	}
	
	// Build the default list of gametypes
	level.defaultGametypeList = buildListFromArrayKeys( level.supportedGametypes, ";" );
	
	// Load the name of the stock maps
	level.stockMapNames = [];
	level.stockMapNames["mp_array"] = "Array";
	level.stockMapNames["mp_berlinwall2"] = "Berlin Wall";
	level.stockMapNames["mp_gridlock"] = "Convoy";
	level.stockMapNames["mp_cracked"] = "Cracked";
	level.stockMapNames["mp_crisis"] = "Crisis";
	level.stockMapNames["mp_discovery"] = "Discovery";
	level.stockMapNames["mp_drivein"] = "Drive-In";
	level.stockMapNames["mp_firingrange"] = "Firing Range";
	level.stockMapNames["mp_duga"] = "Grid";
	level.stockMapNames["mp_area51"] = "Hangar 18";
	level.stockMapNames["mp_hanoi"] = "Hanoi";
	level.stockMapNames["mp_cairo"] = "Havana";
	level.stockMapNames["mp_golfcourse"] = "Hazard";
	level.stockMapNames["mp_hotel"] = "Hotel";
	level.stockMapNames["mp_havoc"] = "Jungle";
	level.stockMapNames["mp_kowloon"] = "Kowloon";
	level.stockMapNames["mp_cosmodrome"] = "Launch";
	level.stockMapNames["mp_nuked"] = "Nuketown";
	level.stockMapNames["mp_radiation"] = "Radiation";
	level.stockMapNames["mp_silo"] = "Silo";
	level.stockMapNames["mp_stadium"] = "Stadium";
	level.stockMapNames["mp_outskirts"] = "Stockpile";
	level.stockMapNames["mp_mountain"] = "Summit";
	level.stockMapNames["mp_villa"] = "Villa";
	level.stockMapNames["mp_russianbase"] = "WMD";
	level.stockMapNames["mp_zoo"] = "Zoo";
	
	// Build the default list of maps
	level.defaultMapList = buildListFromArrayKeys( level.stockMapNames, ";" );
}


buildListFromArrayKeys( arrayToList, delimiter )
{
	newList = "";
	arrayKeys = getArrayKeys( arrayToList );
	
	for ( i = 0; i < arrayKeys.size; i++ ) {
		if ( newList != "" ) {
			newList += delimiter;
		}
		newList += arrayKeys[i];		
	}	

	return newList;
}